<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P196 【例8-3】demo03.html</title>
</head>

<body>
    <p>用户姓名：<input type="text"></p>
    <p>电子邮箱：<input type="text"></p>
    <p>手机号码：<input type="text"></p>
    <p>个人描述：<input type="text"></p>
    <script>
        var inputs = document.getElementsByTagName('input');
        for (var i = 0; i < inputs.length; ++i) {
            inputs[i].onkeydown = function (e) {
                var e = event || window.event;
                if (e.keyCode === 13) {
                    for (var i = 0; i < inputs.length; ++i) {
                        if (inputs[i] === this) {
                            var index = i + 1 >= inputs.length ? 0 : i + 1;
                            break;
                        }
                    }
                    if (inputs[index].type === 'text') {
                        inputs[index].focus();
                    }
                }
            };
        }
    </script>
    <a href="../首页/page08.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>